package com.bw.usercenter.model.service

import com.bw.net.RetrofitFactory
import com.bw.net.protocol.resp.BaseRespEntity

import com.bw.usercenter.contract.UserCenterContract
import com.bw.usercenter.model.api.UserCenterApi
import com.bw.usercenter.model.protocol.req.UserEntitiy
import com.bw.usercenter.model.protocol.resp.*
import io.reactivex.Observable
import io.reactivex.Observer

class UserCenterModelImpl:UserCenterContract.UserContractModel {
    val service= RetrofitFactory.retrofitInseance.create(UserCenterApi::class.java)
    override fun register(enity: UserEntitiy): Observable<BaseRespEntity<RespUserEntity>> {
        return service.register(enity)
    }

    override fun login(enity: UserEntitiy): Observable<BaseRespEntity<RespUserEntity>> {
        return service.login(enity)
    }

    override fun requestTB(page: Int): Observable<RespGoodEntity> {
        return service.requestTB("api/Goods/getRecommendGoods?page="+page+"&pagesize=30")
    }

    override fun getRecomment(): Observable<RespRecommendEntity> {
        return service.getRecomment()
    }

    override fun getauthcode(): Observable<Int> {
        return service.authcode()
    }

    override fun getSrarch(name: String): Observable<RespSearchEntity> {
        return service.getSearch("api/Goods/getGoods?keyword="+name+"&type= &pageno=1&pagesize=30")
    }

    override fun getSearchitem(string: String): Observable<RespSearchitemIDEntity> {
        return service.getSearchitemID(string)
    }


}